<template>
    <div>
        <h2>登录1</h2>
        <tabel border="1">
            <tr>
                <td>用户名</td>
                <td>
                    <input type="text" placeholder="请输入用户名" v-model="info.Name">
                </td>
            </tr>
            <tr>
                <td>密码</td>
                <td>
                    <input type="password" placeholder="请输入密码" v-model="info.Pwd">
                </td>
            </tr>

            <tr>
                <td colspan="2">
                    <input type="button" value="登录" @click="login">
                </td>
            </tr>
        </tabel>
    </div>
</template>

<script setup lang="ts">
import{ref,reactive,onMounted}from 'vue';
import axios from 'axios';

const info=ref({
    Name:'',
    Pwd:''
})

const login=()=>{
    if(info.value.Name==""){
        alert("用户名不能为空");
        return;
    }
    if(info.value.Pwd==""){
        alert("密码不能为空");
        return;
    }
    axios.get('https://localhost:7291/api/Member/Login',{
        params:{
            name:info.value.Name,
            pwd:info.value.Pwd
        }
    })
    .then(res=>{
        if(res.data==-1){
            alert("密码错误");
            return;
        }
        else if(res.data==-2)
        {
            alert("用户名错误");
            return;
        }
        else if(res.data>0)
        {
            alert("登录成功");
        }
    })
    .catch(err=>{
        console.log(err);
    })
}


</script>

<style scoped>

</style>